<template>
  <el-dialog
    title="发布优惠信息"
    :visible="visible"
    width="800px"
    @close="close"
  >
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item prop="title" label="标题">
        <el-input v-model="form.title" placeholder="请填写优惠标题" maxlength="20"></el-input>
      </el-form-item>
      <el-form-item prop="content" label="内容">
        <el-input type="textarea" v-model="form.content" placeholder="请填写优惠内容" rows="5"></el-input>
      </el-form-item>
      <el-form-item label="优惠图">
        <el-upload
          action="https://jsonplaceholder.typicode.com/posts/"
          list-type="picture-card">
          <i class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="save" :loading="loading">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'DiscountRelease',
  data() {
    return {
      visible: true,
      form: {
        title: '',
        content: ''
      },
      rules: {
        title: [{
          required: true,
          message: '请填写标题'
        }],
        content: [{ required: true, message: '请填写优惠内容' }]
      },
      loading: false
    };
  },
  methods: {
    close() {
      this.$emit('close');
    },
    save() {
      this.loading = true;
      setTimeout(() => {
        this.visible = false;
        this.loading = false;
        this.$message({
          type: 'success',
          message: '发布成功'
        });
      }, 1000);
    }
  }
};
</script>

<style>

</style>
